/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pingouin;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Hippolyte
 */
public class TClientRessources extends Thread {

    public final String awake = new String();

    public TClientRessources() {
    }

    @Override
    public void run() {

        while (true) {
            InputStream is;
            try {
//            adda = Inet4Address.getByAddress(add);
                ServerSocket ss = new ServerSocket(TServeurRessources.PORT);
                Socket socket = ss.accept();
                is = socket.getInputStream();
                ObjectInputStream ois = new ObjectInputStream(is);

                Ressources l = (Ressources) ois.readObject();

                System.out.println("receptionne socket");

                if (l != null && !l.hexas.isEmpty()) {
                    Partie.ressources = l;
                    System.out.println("receptionne socket");
                }

                is.close();
                socket.close();
                ss.close();
            } catch (UnknownHostException ex) {
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
                return;
            } catch (ClassNotFoundException cnf) {
                System.out.println(cnf);
            } catch (IOException ioe) {
                System.out.println(ioe);
            }
            try {
                sleep(100);
            } catch (InterruptedException ex) {
                Logger.getLogger(TClientRessources.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
